﻿using System;
using System.Collections.Generic;
using UnityEngine;

// Token: 0x02000008 RID: 8
public class CameraController : MonoBehaviour
{
	// Token: 0x06000029 RID: 41 RVA: 0x00006F20 File Offset: 0x00005120
	private void Start()
	{
		CameraController.main = this;
	}

	// Token: 0x0600002A RID: 42 RVA: 0x00006F28 File Offset: 0x00005128
	public void UpdatePoints()
	{
		this.CameraPoints.Clear();
		this.CameraPoints.AddRange(Object.FindObjectsOfType<CameraPoint>());
	}

	// Token: 0x0600002B RID: 43 RVA: 0x00006F48 File Offset: 0x00005148
	private void Update()
	{
		if (this.CameraPoints.Count > 0 && this.checkTransform)
		{
			this.checkTime -= Time.deltaTime;
			if (this.checkTime <= 0f)
			{
				this.checkTime = 0.3f;
				CameraPoint cameraPoint = null;
				float num = 99999f;
				foreach (CameraPoint cameraPoint2 in this.CameraPoints)
				{
					if (Vector2.Distance(cameraPoint2.transform.position, this.checkTransform.position) < num)
					{
						num = Vector2.Distance(cameraPoint2.transform.position, this.checkTransform.position);
						cameraPoint = cameraPoint2;
					}
				}
				this.curPoint = cameraPoint;
			}
			if (this.curPoint)
			{
				Camera.main.orthographicSize = Mathf.Lerp(Camera.main.orthographicSize, this.curPoint.camSize, 3f * Time.deltaTime);
				Camera.main.transform.position = Vector2.Lerp(Camera.main.transform.position, this.curPoint.transform.position + (this.checkTransform.position - this.curPoint.transform.position) * this.curPoint.offsetMult, 3f * Time.deltaTime);
				Camera.main.transform.position = new Vector3(Camera.main.transform.position.x, Camera.main.transform.position.y, -1.5f);
			}
		}
	}

	// Token: 0x040000A3 RID: 163
	public List<CameraPoint> CameraPoints = new List<CameraPoint>();

	// Token: 0x040000A4 RID: 164
	private float checkTime;

	// Token: 0x040000A5 RID: 165
	public Transform checkTransform;

	// Token: 0x040000A6 RID: 166
	private CameraPoint curPoint;

	// Token: 0x040000A7 RID: 167
	public static CameraController main;
}
